package com.base.service.impl;

import com.base.mapper.voipmapper.RefundMapper;
import com.base.po.voip.Refund;
import com.base.service.RefundService;
import com.base.utils.Page;
import com.base.utils.Produce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author PQ
 * @Date 2019/8/23 11:22
 */
@Service("refundService")
public class RefundServiceImpl implements RefundService {

    @Autowired
    RefundMapper refundMapper;

    @Override
    public Integer insertNews(String userId, String parentId, String orderId, String remark) {
        int status=0;
        Date createTime=new Date();
        Refund r=new Refund();
        r.setId(Produce.getUUID());
        r.setCreateTime(createTime);
        r.setParentId(parentId);
        r.setRemark(remark);
        r.setOrderId(orderId);
        r.setUserId(userId);
        return  refundMapper.insertNews(r);
    }

    @Override
    public Integer countByAll(String userId, String orderId, String parentId, String createTime, String status,String orderNum) {

        return refundMapper.countByAll(userId,  orderId,  parentId,  createTime,  status,orderNum);
    }

    @Override
    public List<Refund> selectByAll(Page page,String userId, String orderId, String parentId, String createTime, String status,String orderNum) {

        return refundMapper.selectByAll(page, userId,  orderId,  parentId,  createTime,  status,orderNum) ;
    }

    @Override
    public void updateStatus(String id,int status) {

         refundMapper.updateStatus(id,status);
    }

    @Override
    public boolean isRefund(String orderId) {
        int count= refundMapper.isRefund(orderId);

        return count> 0;

    }

    @Override
    public String getIdByOrderId(String Orderid) {
          String id=  refundMapper.getIdByOrderId( Orderid);
        return id;
    }

//    @Override
//    public Integer countByAllRecord(String parentId) {
//        return refundMapper.countByAllRecord(parentId);
//    }
}
